<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">所属组别</label>
        <div class="layui-input-block">
            <div id="demo1" class="xm-select-demo"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属上级</label>
        <div class="layui-input-block">
            <div id="demo2" class="xm-select-demo"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属部门</label>
        <div class="layui-input-block">
            <div id="demo3" class="xm-select-demo"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" required lay-verify="username" placeholder="请输入用户名" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
            <input type="text" name="mobile" required lay-verify="phone" placeholder="请输入手机号" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">Email</label>
        <div class="layui-input-block">
            <input type="text" name="email" required lay-verify="email" placeholder="请输入Email"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">昵称</label>
        <div class="layui-input-block">
            <input type="text" name="nickname" required lay-verify="nickname" placeholder="请输入昵称" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" required lay-verify="pass" placeholder="请输入密码" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">生日</label>
        <div class="layui-input-block">
            <input type="text" name="birthday" required lay-verify="birthday" placeholder="请输入生日(比如:2-4)"
                   autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">节点</label>
        <div class="layui-input-block">
            <input type="radio" name="lunar" value="0" title="阳历" checked>
            <input type="radio" name="lunar" value="1" title="农历">

        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="正常" checked>
            <input type="radio" name="status" value="0" title="禁用">
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="LAY-user-back-submit" id="LAY-user-back-submit" value="确认">
    </div>
</div>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/admin/js/xm-select.js"></script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$, form = layui.form;
        form.render();
        form.verify({
            username: function (value) {
                if (value.length < 5) {
                    return '用户名至少得5个字符';
                }
            }, nickname: function (value) {
                if (value.length < 2) {
                    return '昵称至少2位字符';
                }
            }
            , pass: [
                /^[\S]{6,12}$/
                , '密码必须6到12位，且不能出现空格'
            ]
            , phone: [/^1[3|4|5|7|8|9]\d{9}$/, '手机必须11位，只能是数字or格式不对！']
            , email: [/^[a-z0-9._%-]+@([a-z0-9-]+\.)+[a-z]{2,4}$|^1[3|4|5|7|8|9]\d{9}$/, '邮箱格式不对']
        });
        $.ajax({
            url: "{:url('admin/groupTree')}",
            type: 'post',
            dataType: 'json',
            success: function (res) {
                xmSelect.render({
                    el: '#demo1',
                    filterable: true,
                    data: res
                })
            }
        });
        $.ajax({
            url: "{:url('admin/dept')}",
            type: 'post',
            dataType: 'json',
            success: function (res) {
                xmSelect.render({
                    el: '#demo2',
                    radio: true,
                    name:'department_id',
                    filterable: true,
                    data: res
                })
            }
        });
        $.ajax({
            url: "{:url('admin/dept')}",
            type: 'post',
            dataType: 'json',
            success: function (res) {
                xmSelect.render({
                    el: '#demo3',
                    radio: true,
                    name:'dept_id',
                    filterable: true,
                    data: res
                })
            }
        });
    })
</script>

